package com.company.OfferGuide;

import com.company.TreeNode;

public class 树的子结构 {

    public boolean isSubStructure(TreeNode A, TreeNode B) {
        if (A == null || B == null) return false;
        return dfs(A,B) || isSubStructure(A.left,B) || isSubStructure(A.right,B);
    }

    public boolean dfs(TreeNode node01,TreeNode node02) {
        if (node01 == null) return false;
        if (node02 == null) return true;

        return node01.val == node02.val && dfs(node01.right,node02.right) && dfs(node01.left,node02.left);

    }

}
